class_name Enemy
extends CharacterBody2D

#属性
@export var detection_radius = 200.0 # 侦察区域半径
@export var attack_radius = 50.0 # 攻击区域半径
var player_detected = false
var respawn_timer = Timer.new() # 用于复活计时
const RUN_SPEED=50.00
const ACCECELARATION=RUN_SPEED/0.2

@onready var animated_sprite_2d = $Graphics/AnimatedSprite2D

@export var endPoint:Marker2D
signal died # 新增信号，用于通知敌人死亡
signal parasited(enemy) # 新增信号，用于通知敌人被寄生

# 敌人脚本
var health = 100  # 假设敌人有100点生命值

#func die():
	#respawn_timer.start() # 开始复活倒计时
	#add_to_group("can_be_parasited")
	#emit_signal("died")
	#velocity=Vector2(0,0)
	#
#func parasite():
	#emit_signal("parasited", self)
	## 可以在这里添加更多逻辑，比如加入主角队伍
func _ready():
	add_to_group("enemy")
	#start_position=position
	#end_position=endPoint.global_position
	#add_to_group("monster")
	#add_child(respawn_timer)
	#respawn_timer.wait_time = 20 # 20秒后复活
	#respawn_timer.one_shot = true
	#respawn_timer.connect("timeout", self, "_on_Respawn_Timer_timeout")
func take_hit(value:int):
	health=health-value
	$FSM.change_state(2)
	pass

func get_enemy_frames():
	return "scissor"

#func _on_respawn_timer_timeout():
	#health = 100 # 恢复生命值
	#animated_sprite_2d.play("Idle")


